<?php
/*
 * @Author: your name
 * @Date: 2020-06-05 17:32:41
 * @LastEditTime: 2020-10-13 17:22:04
 * @LastEditors: Please set LastEditors
 * @Description: 业务系统管理
 * @FilePath: /special/application/adminapiv3/controller/asset_manage/SoftwareController.php
 */

namespace app\adminapiv3\controller\asset_manage\software;

//业务系统
use app\adminapiv3\controller\BaseController;
use app\adminapiv3\service\asset_manage\software\SoftwareService;
use think\Request;

class SoftwareController extends BaseController
{
    /**
     * @name 列表
     * @author wx
     * @date 2019/10/23 15:11
     */
    public function list(Request $request)
    {
        //接收参数
        $params = $request->only([
            'name','status','description','on_time','off_time'
        ],'get');

        $server = new SoftwareService();
        $list = $server->list($params);

        return $this->jsonOutPut($list);
    }

    /**
     * @name 添加
     * @author wx
     * @date 2019/10/23 15:40
     */
    public function add(Request $request)
    {
        $params = $request->only([
            'name','on_time','description'
        ],'post');
        $this->validate($params,'Software.add');

        $server = new SoftwareService();
        $server->add($params);

        return $this->jsonOutPut();
    }

    /**
     * @name 修改
     * @author wx
     * @date 2019/10/23 15:42
     */
    public function modify(Request $request)
    {
        $params = $request->only([
            'id','name','on_time','description','status'
        ],'post');
        $this->validate($params,'Software.modify');

        $server = new SoftwareService();
        $server->modify($params['id'], $params);

        return $this->jsonOutPut();
    }

    /**
     * @name 删除
     * @author wx
     * @date 2019/10/23 15:57
     */
    public function del(Request $request)
    {
        $params = $request->only([
            'id'
        ],'post');
        $this->validate($params,'Software.del');

        $server = new SoftwareService();
        $server->del($params['id']);

        return $this->jsonOutPut();
    }

    /**
     * @name 退役
     * @author wx
     * @date 2019/10/23 15:57
     */
    public function retire(Request $request)
    {
        $params = $request->only([
            'id'
        ],'post');
        $this->validate($params,'Software.retire');

        $server = new SoftwareService();
        $server->retire($params['id']);

        return $this->jsonOutPut();
    }

}